// todo 默认配置
const {resolve} = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin')

module.exports = {
    entry: './src/index.js',
    output: {
        path: resolve(__dirname, 'dist'),
        filename: 'index.js'
    },
    mode: 'development',
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader', "postcss-loader"]
            },
            {
                test: /\.s(c|a)ss$/,
                use: ['style-loader', 'css-loader', "postcss-loader", 'sass-loader']
            },
            {
                test: /\.less$/,
                use: ['style-loader', 'css-loader', "postcss-loader", 'less-loader']
            },
            {
                test: /\.js$/,
                exclude: [resolve(__dirname, './node_modules')],
                use: ['babel-loader']
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './public/index.html'
        }),
        new CleanWebpackPlugin()
    ]
}